#!/bin/ksh

LOGIN=$1
SH_DIR=$2
UP_DIR=$3
UP_FILE=$4
RPT_DATE=$5
BU_TYPE=$6 

sqlplus -s $LOGIN<<!
DELETE FROM CCS.CCS_AMS_TMP_INFOLINE;
COMMIT;
!

cat > $UP_DIR/ctl/Upload_Infoline.ctl<<!
LOAD DATA
INFILE '$UP_DIR/$UP_FILE'
APPEND INTO TABLE CCS.CCS_AMS_TMP_INFOLINE
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
(
MOBILE_NO,
CALL_DATE,
CALL_TIME,
CALL_NO,
CALL_DURATION,
NETWORK,
BU_TYPE CONSTANT  '$BU_TYPE'
)
!

cd $UP_DIR/
/usr/local/bin/dos2unix $UP_FILE
sqlldr $LOGIN \
control=$UP_DIR/ctl/Upload_Infoline.ctl bad=$UP_DIR/bad/Upload_Infoline.bad \
log=$UP_DIR/log/Upload_Infoline.log >> $UP_DIR/log/Upload_Infoline.log
